package banksimulator.test;

import banksimulator.bank.AbstractBank;
import banksimulator.bank.BasicAccount;
import banksimulator.bank.MemoryBank;
import banksimulator.ui.MainFrame;
import javax.swing.UIManager;

/**
 *
 * @author Rajab
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public void testAccount() {
        //        AbstractBank b = new MemoryBank("中国银行");
        //
        //        BasicAccount ac1 = new BasicAccount("Rajab", 2000);
        //        BasicAccount ac2 = new BasicAccount("Leon", 1000);
        //        BasicAccount ac3 = new BasicAccount("Simon", 4000);
        //        b.addAccount(ac1);
        //        b.addAccount(ac2);
        //        b.addAccount(ac3);
        //
        //
        //
        //        ac1.deposit(1000);
        //        ac1.deposit(500);
        //        try {
        //            ac2.withdraw(500);
        //        } catch (FundsInsufficientException ex) {
        //            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        //        }
        //        ac3.deposit(2340);
        //        try {
        //            ac2.withdraw(453);
        //        } catch (FundsInsufficientException ex) {
        //            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        //        }
        //        try {
        //            ac1.withdraw(200);
        //        } catch (FundsInsufficientException ex) {
        //            System.out.println(ex);
        //        }
        //
        //        SimpleDateFormat fmt = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
        //        for (AbstractAccount a : b) {
        //            System.out.println(a);
        //
        //            for (Transaction t : a.allTranscation()) {
        //                System.out.printf("%s %s->%s %s %.2f\n",
        //                        fmt.format(t.getCommitTime()), t.getFromAccountID(),
        //                        t.getToAccountID(), t.getDescription(), t.getAmount());
        //            }
        //
        //        }
    }

    public static void main(String[] args) {
        //testAccount();
        setupLookAndFeel();
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {

                AbstractBank bank = new MemoryBank("中国银行");

//                bank.addAccount(accountFactory.create("Kim", 1235.32));
//                bank.addAccount(accountFactory.create("Lucy", 2345));
//                bank.addAccount(accountFactory.create("Wang", 4512));
//                bank.addAccount(accountFactory.create("Ma", 3500.23));
//                bank.addAccount(accountFactory.create("Michael", 634));
//                bank.addAccount(accountFactory.create("Jim", 734));
//                bank.addAccount(accountFactory.create("Sion", 135456.3));
//                bank.getAccount(0).deposit(2345.4);
//                bank.getAccount(1).deposit(123.5);
                new MainFrame(bank, BasicAccount.factory).setVisible(true);
            }
        });
    }

    private static void setupLookAndFeel() {

        try {
            UIManager.setLookAndFeel(new org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel());
        } catch (Exception ex) {
            System.out.println(ex);
        }
    }
}
